package com.wanmait.recycle.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.wanmait.recycle.pojo.Question;
import com.wanmait.recycle.pojo.Rubbish;
import com.wanmait.recycle.service.QuestionService;

@Controller
@RequestMapping("/manager/question")
public class QuestionController {

	@Resource	
	private QuestionService questionService;
	
	@RequestMapping("questionList")
	@ModelAttribute("questions")
	public List<Question> questionShow() {
		
		return questionService.findAll();
	}
	
	//问题上线
	@RequestMapping("update")
	@ResponseBody
	public void update(Integer id) {
	
		questionService.shangXian(id);
	}
	
	
	//问题下线
	@RequestMapping("below")
	@ResponseBody
	public void below(Integer id) {
	

		questionService.xiaXian(id);
	}
	
	//多问题上线
	@RequestMapping("updateMO")
	@ResponseBody
	public void update1(String ids) {


		questionService.shangXianByIds(ids);
	}
	
	
	//多问题下线
	@RequestMapping("belowMO")
	@ResponseBody
	public void below1(String ids) {
	

		questionService.xiaXianByIds(ids);
	}
	
	@RequestMapping("questionSingle")
	public ModelAndView questionSingle(Integer questionId)
	{
		
		ModelAndView mv = new ModelAndView();
		Question questions =  questionService.findById2(questionId);
		
		mv.addObject("questions", questions);
			
		return mv;
		
	}
	
}
